<?php


namespace App\Api\Controllers;


use App\Api\Services\ApiService;
use App\Models\Competition;
use App\Models\Matchs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;


class ApiController extends BaseController {
    protected $service;

    public function __construct(Request $request, ApiService $ApiService) {
        parent::__construct($request);
        $this->service = $ApiService;
    }

    function category_list() {
        $dataList = Competition::select('id', 'name', 'nameFull', 'currSeason', 'seasons')
            ->where('id', '<', 30)
            ->get()
            ->toArray();
        dd($dataList);
    }

    function match_list() {
        $today = Carbon::now()->toDateString();
        $start = Carbon::today()->format('Y-m-d H:i:s');
        $end = Carbon::tomorrow()->format('Y-m-d H:i:s');
        $dataList = Matchs::where('id','>',0)
            //->whereBetween('created_at', [$start, $end])
            ->whereDate('created_at', $today)
            ->toSql();
        var_dump($dataList);
    }

    function index() {
        $this->service->index();
    }
}
